#include <iostream>
#include <cstring>

using namespace std;
class Phone
{
    int number = 0, state = 0;
    char type = 0;
    char *name = 0;

public:
    Phone(){};
    void setPhone()
    {
        char nam[10];
        cin >> number >> type >> state >> nam;
        name = new char[strlen(nam) + 1];
        strcpy(name, nam);
        cout << number << " constructed." << endl;
    }
    int search(int num)
    {
        return (number == num ? 1 : 0);
    }
    void print(int n)
    {
        cout << "Phone=" << n << "--Type=" << type;
        if (state)
            cout << "--State=use--Owner=";
        else
            cout << "--State=unuse--Owner=";
        cout << name << endl;
    }
    ~Phone()
    {
        cout << number << " destructed." << endl;
    }
};

int main()
{
    int t;
    Phone *p = new Phone[3];
    for (int i = 0; i < 3; i++)
    {
        (p + i)->setPhone();
    }
    cin >> t;
    while (t--)
    {
        int number, flag = 0;
        cin >> number;
        for (int i = 0; i < 3; i++)
        {
            flag = (p + i)->search(number);
            if (flag)
            {
                (p + i)->print(number);
                break;
            }
        }
        if (!flag)
        {
            cout << "wrong number." << endl;
        }
    }
    delete[] p;
    return 0;
}
